init;
global n k m

msg = [0 5 1];

fprintf('Original message:  ');
disp(msg);

% Generate ground truth with Matlab's RSENC
% gf_msg = gf(msg,m);
% code = rsenc(gf_msg,n,k);

%Encode
T=RS_encoder(msg)
fprintf('Transmitted Code Word: ');
printPoly(T);

%Add errors
%T(1) = 3;
%T(3) = 7;
%T(4) = 6;

disp('T')
T

%Decode
T_dec = euclid(T);

%Recover M(x) - easy to do since this is a systematic code
M = T_dec(end-k+1:end);
fprintf('\nRecovered message: ');
disp(fliplr(M));